package com.it.controller;


import com.it.service.IExamRecordService;
import com.it.util.Result;
import com.it.util.ThreadLocalUtil;
import com.it.vo.ExamRecordVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2023-09-26
 */
@RestController
@RequestMapping("/examRecord")
public class ExamRecordController {
    @Resource
    IExamRecordService examRecordService;
    @GetMapping("/examRecordList")
    Result<List<ExamRecordVo>> getExamRecordList(){
        Long userId = ThreadLocalUtil.getUserId();
        List<ExamRecordVo> recordsByUserId = examRecordService.findExamRecordsByUserId(userId);
        return Result.success(recordsByUserId);
    }

    @GetMapping("/examScoreList")
    Result<Map<Date,Integer>> getExamScoreList(){
        Long userId = ThreadLocalUtil.getUserId();
        Map<Date,Integer> examScores = examRecordService.findExamScoreByUserId(userId);
        return Result.success(examScores);
    }
}
